home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8411.arc
/
ALIGN.C
next >
Wrap
Text File
|
1986-09-14
|
896b
|
24 lines
/* align.c - align a buffer so that it does not cross */
/* a 64K physical address boundary */
/* We give it the address of a buffer area */
/* It returns a starting address such that the following (size) bytes */
/* do not cross a 64K byte address boundary. */
#include "stdio.h"
unsigned get_ds() ;
char *align(area,size) /* align buffer address */
char *area ; /* start of buffer area */
int size ; /* size required for buffer */
{ /* returns an aligned address */
long begin ; /* flat address for area */
unsigned room ; /* number of bytes to boundary */
/* build flat address */
begin = ((long) get_ds() ) * 16L + (long) area ;
room = 0x10000 - (begin & 0xffff) ; /* get distance to boundary */
if( room >= size )
return( area ) ;
else return( area + room ) ;
}